<%@include file="/WEB-INF/jsp/common/taglibs.jsp"%>

<s:layout-render name="/WEB-INF/jsp/common/layout_main.jsp"
                 title="Create Group Information">
    <s:layout-component name="body">
        <script type="text/javascript" src="js/jquery.searchabledropdown-1.0.7.min.js"></script>
        <script type="text/javascript">
            
            var str = "";
            var data=[];
            var valor;
            function addnewclient()
            {
                $("#ddmember option:selected").each(function () {
                    str = $(this).text() + "<br/>";
                    valor = $(this).val();
                });
                //alert(data.join('\n'));
                if(str == "Select One<br/>")
                {
                    alert('Please select one member');        
                }
                else
                {	
                    var rta = $.inArray(parseInt(valor),data);
                    if(rta > -1)
                    {
                        alert('This member has already been added. Please choose another one.');  
                       
                    }
                    else
                    {
                        $("#divapp").append(str);  
                        data.push(parseInt(valor));  
                    }
                }
                document.getElementById('userList').value = data;
            }
                
            $(document).ready(function() {
                $("#ddmember").searchable();
            });

        </script>
        <s:form beanclass="spatialmarketplace.cem.action.CreateGroupFormActionBean">
            <s:errors/>
            <div><s:hidden name="group.groupId"/></div>

            <div id="divborder">
                <br/><br/>
                <div align="left"><span id="s-Label_1">Create Group</span></div>
                <br/>
                <br/>
                <table style="margin-left:100px;" cellpadding="8" cellspacing="12">
                    <tr>
                        <td><label class="labelName">Name :</label></td>
                        <td style="font-size:10px; text-align: right; color: red;"><s:text name="group.name" maxlength="50" class="inputText required" /> *</td>
                    </tr>
                    <tr>
                        <td><label class="labelName">Logo :</label></td>
                        <td ><s:file name="group.file" class="inputText" /></td>
                    </tr>
                    <tr>
                        <td><label class="labelName">Description :</label></td>
                        <td style="font-size:10px; text-align: right; color: red;"><s:textarea name="group.description" class="inputText required" rows="8" /> * </td>
                    </tr>
                    <tr>
                        <td><label class="labelName">Access :</label></td>
                        <td><s:select name="group.accessType"  class="required" style="width:300px">
                                <s:option selected="selected" value="Public" >Public</s:option>
                                <s:option value="PublicIO" >Public (Invite-Only)</s:option>
                                <s:option value="Private" >Private</s:option>
                            </s:select>
                        </td>
                    </tr>
                    <tr>
                        <td><label class="labelName">Keywords :</label></td>
                        <td style="font-size:10px; text-align: right; color: red;"><s:text name="group.keyword" maxlength="200" class="inputText required" title="A space or comma-separated list of keywords" /> * </td>

                    </tr>

                    <tr>
                        <td><label class="labelName">Add Member :</label></td>
                        <td style="font-size:10px; color: red;">
                           
                            <s:select name="usersList" style="width:290px;" id="ddmember" title="Once a member is selected, please press the green botton to add it." >
                                <s:option value="" >Select One</s:option> 
                                <s:options-collection collection="${actionBean.users}" value="userId" label="userName" />
                            </s:select></td>
                        <td><img alt="" src="images/add_green.png" border="0" onclick="addnewclient()"/></td>
                    </tr>

                    <tr>
                        <td></td>
                        <td><div id="divapp"><s:hidden id="userList" name="userList"  value="memberListEmpty"/></div></td>
                    </tr>
                    <tr>
                        <td colspan="2" style="font-size:10px; text-align: right; color: red;">(*) fields required.</td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center">
                            <s:submit name="save" value="Save"/>
                            <s:submit name="cancel" value="Cancel"/>
                        </td>
                    </tr>
                </table>
            </div>
        </s:form>
    </s:layout-component>
</s:layout-render>



